<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('选择用户')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="user-form">
					<input type="hidden" id="deptId" name="deptId">
					<input type="hidden" id="deptParentId" name="deptParentId">
					<div class="select-list">
						<ul>
							<li>
								用户名称：<input type="text" name="userName"/>
							</li>
							<li>
								登录名称：<input type="text" name="loginName"/>
							</li>
							<li>
								手机号码：<input type="text" name="phonenumber"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>

			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>

	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/user";
        var datas = [[${@dict.getType('sys_normal_disable')}]];

        $(function() {
			queryUserList();
        });

		function queryUserList() {
			var options = {
				url: prefix + "/list",
				showSearch: false,
				showRefresh: false,
				showToggle: false,
				showColumns: false,
				sortName: "createTime",
				sortOrder: "desc",
				modalName: "用户",
				columns: [{
						radio: true
					},
					{
						field: 'userId',
						title: '用户ID',
						visible: false
					},
					{
						field: 'loginName',
						title: '登录名称',
						sortable: true
					},
					{
						field: 'userName',
						title: '用户名称',
						sortable: true
					},
					{
						field: 'dept.deptName',
						title: '部门',
						sortable: true
					},
					{
						field: 'phonenumber',
						title: '手机'
					},
					{
						field: 'status',
						title: '用户状态',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(datas, value);
						}
					},
					{
						field: 'createTime',
						title: '创建时间',
						sortable: true
					}]
			};
			$.table.init(options);
		}

		function getSelections() {
			var rows = $("#bootstrap-table").bootstrapTable('getSelections');
			if(rows.length==0)
			{
				$.modal.alertWarning("请至少选择一条记录");
				return;
			} else if (rows.length>1)
			{
				$.modal.alertWarning("不能选择多条记录");
				return;
			}

			var retObj={};
			retObj.userId = rows[0].userId;
			retObj.userName = rows[0].userName;
			return retObj;
		}

		function resetPre() {
			resetDate();
			$("#user-form")[0].reset();
			$("#deptId").val("");
			$("#deptParentId").val("");
			$(".curSelectedNode").removeClass("curSelectedNode");
			$.table.search();
		}
    </script>
</body>
</html>